Note

This behavior is added since WebWork 2.2.4 (in the XWork bundle that comes with it). See XW-422 for more information.

WebWork's validators are designed to be as independent of each other as possible, such that a validator like 'stringlength' should just validate the lenght of the input string. It will not attempt to validate an empty string as that would overlap with the 'requiredstring' validator, for example.

If we need to validate against an input that should not be empty and should have a certain length, we would apply the following validator sequence :

  • 'requiredstring' validator
  • 'stringlength' validator

If we need to validate against an input that should have a certain length but it doesn't matter if nothing is specified, we could apply the following validator sequence :

  • 'stringlength' validator

Without the concept of 'independent responsibility' in each validator design, the second case in the above described senarios would not be possible to achieve.

For more information about validators, have a look at Validation.